package com.projet.word;

public class TestWordMain {
    public static void main(String[] args) {
        try {
//          System.out.println(isOk("${${qweqw}"));
//            System.out.println(isOk("${qweqw}${"));
            System.out.println(isOk("${qweqw}1231232}123123"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //开始符
    private static final String VAR_BEGIN = "${";
    //结束符
    private static final String VAR_END = "}";
    //换行符号
    private static final String BR = "<####BrrB##>";


    /**
     * 是否闭合
     *
     * @param txt
     * @return
     * @throws Exception
     */
    private static boolean isOk(String txt) {
        int b;
        int e;
        int start = 0;
        while (true) {
            b = txt.indexOf(VAR_BEGIN, start);
            if (b < 0) {
                return true;
            }
            e = txt.indexOf(VAR_END, b + 1);
            if (e < 0) {
                return false;
            }
            start = e + 1;
        }
    }

}
